package com.outsourcing.bottle.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;

import com.outsourcing.bottle.R;
import com.outsourcing.bottle.ui.SetAvatarAndNameActivity;
import com.outsourcing.bottle.util.AppContext;
/**
 * 
 * @author 06peng
 *
 */
public class RegisterFragment extends Fragment {

	int currentItem;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.register_fragment, null);
		ImageView logo = (ImageView) view.findViewById(R.id.logo);
		ImageView logoTips = (ImageView) view.findViewById(R.id.logo_tips);
		ImageButton button = (ImageButton) view.findViewById(R.id.register_finish);
		Bundle bundle = getArguments();
		if (bundle != null) {
			currentItem = bundle.getInt("logo");
			switch (currentItem) {
			case 1:
				logo.setImageResource(R.drawable.splash_slide_1);
				if (AppContext.language == 1) {
					logoTips.setImageResource(R.drawable.text_01_cn);
				} else {
					logoTips.setImageResource(R.drawable.text_01_en);
				}
				break;
			case 2:
				logo.setImageResource(R.drawable.splash_slide_2);
				if (AppContext.language == 1) {
					logoTips.setImageResource(R.drawable.text_02_cn);
				} else {
					logoTips.setImageResource(R.drawable.text_02_en);
				}
				break;
			case 3:
				logo.setImageResource(R.drawable.splash_slide_3);
				if (AppContext.language == 1) {
					logoTips.setImageResource(R.drawable.text_03_cn);
				} else {
					logoTips.setImageResource(R.drawable.text_03_en);
				}
				break;
			case 4:
				logo.setImageResource(R.drawable.splash_slide_4);
				if (AppContext.language == 1) {
					logoTips.setImageResource(R.drawable.text_04_cn);
				} else {
					logoTips.setImageResource(R.drawable.text_04_en);
				}
				button.setVisibility(View.VISIBLE);
				button.setOnClickListener(new View.OnClickListener() {
					
					@Override
					public void onClick(View v) {
						Intent intent = new Intent(getActivity(), SetAvatarAndNameActivity.class);
						getActivity().startActivity(intent);
					}
				});
				break;
			default:
				logo.setImageResource(R.drawable.logo_new);
				break;
			}
		}
		return view;
	}
	
}
